/**
 * 二维方格上走步，模拟一下即可
 * 
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;


using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;
using pll = pair<llt, llt>;

llt const INF = 0x7F1F2F3F4F5F6F7F;

int const DR[] = {-1, 1, 0, 0};
int const DC[] = {0, 0, -1, 1};

int N;
int M;
vector<string> Board;
int Sr, Sc;
string X;

void proc(int & x, int & y, char ch){
    int i = -1;
    switch(ch){
        case 'U': i = 0; break; case 'D': i = 1; break; case 'L': i = 2; break; case 'R': i = 3; break; default: assert(0);
    }

    int nx = x + DR[i];
    int ny = y + DC[i];
    if(1 <= nx and nx <= N and 1 <= ny and ny <= M and '.' == Board[nx][ny]){
        x = nx, y = ny;
    }
}

void work(){ 
    cin >> N >> M >> Sr >> Sc;
    Board.assign(N + 1, "");
    for(int i=1;i<=N;++i){
        cin >> Board[i];
        Board[i] = " " + Board[i];
    }

    cin >> X;
    
    int x = Sr, y = Sc;
    for(auto ch : X){
        proc(x, y, ch);
    }
    cout << x << " " << y << endl;
	return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    int nofkase = 1;
	// cin >> nofkase;
	while(nofkase--) work();
	return 0;
}